package com.greenantmall.view;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;

public class MyViewPager extends ViewPager {
	private GestureDetector mGesture = null;

	public MyViewPager(Context context) {
		super(context);
	}

	public MyViewPager(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	public boolean dispatchTouchEvent(MotionEvent ev) {
		super.dispatchTouchEvent(ev);
		requestDisallowInterceptTouchEvent(true);
		super.onTouchEvent(ev);
		if (mGesture != null) {
			mGesture.onTouchEvent(ev);
		}
		return true;
	}

	public void setOnGestureListener(OnGestureListener listener) {
		mGesture = new GestureDetector(listener);
	}
}